package com.zut.blocks.base.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author lxd
 * @date 2020/12/6 21:19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResponse<T> {

    public static int SUCCESS_CODE = 0;
    public static int ERROR_CODE = -1;

    private T data;
    private String message;
    private Integer code;
    private Long total;

    public static <T> CommonResponse<T> success(T data) {
        return new CommonResponse<T>(data, "", SUCCESS_CODE, null);
    }

    public static <T> CommonResponse<T> success(T data, Long total) {
        return new CommonResponse<T>(data, "", SUCCESS_CODE, total);
    }

    public static <T> CommonResponse<T> error(String message) {
        return new CommonResponse<T>(null, message, ERROR_CODE, null);
    }


}
